﻿///-----------------------------------------------------------------------
/// <copyright file="LiquidationListViewITemViewModel.cs" company="FactSet Research Systems, Inc.">
///     Copyright © FactSet Research Systems, Inc.  All rights reserved 2012.
/// </copyright>
/// <author>Jonathan K. Barez</author>
///-----------------------------------------------------------------------
namespace HousholdISv2.ViewModel.Transaction
{
    using System;
    using DataRepository;
    using MVVMCore.ViewModel.Details;

    public class LiquidationListViewItemViewModel : ListViewItemViewModel<LiquidationListViewViewModel, Expense>
    {
        #region Constructors

        /// <summary>
        /// Initializes a new instance of the <see cref="LiquidationListViewItemViewModel"/> class.
        /// </summary>
        public LiquidationListViewItemViewModel(LiquidationListViewViewModel container, Expense data)
            : base(container, data)
        {
            this.Date = data.Date;
            this.Amount = data.Amount;
            if (data.ExpenseType != null)
            {
                this.ExpenseType = data.ExpenseType.Description;
            }
        }

        #endregion Constructors

        #region Properties

        public DateTime Date
        {
            get { return GetValue(() => this.Date); }
            set { SetValue(() => Date, value); }
        }

        public string ExpenseType
        {
            get { return GetValue(() => this.ExpenseType); }
            set { SetValue(() => ExpenseType, value); }
        }

        public decimal Amount
        {
            get { return GetValue(() => this.Amount); }
            set { SetValue(() => Amount, value); }
        }

        public override string Description
        {
            get
            {
                return
                    base.Description ??
                    (base.Description =
                     string.Format("[{0:yyyyMMdd}] {1} - {2:#,##0.00}", this.Date, this.ExpenseType, this.Amount));
            }
            set { base.Description = value; }
        }

        #endregion Properties
    }
}
